package ace.j2se.l2;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class LinuxExec {
	public static void main(String[] args) {
		try {
			// String[] cmd = new String[] { "/bin/sh", "-c", " ls -al" };
			String[] cmd = new String[] { "/bin/sh", "-c", " open " };
			String url = "~/Documents/workspace";
			String s = cmd[cmd.length - 1] + " " + url;
			cmd[cmd.length - 1] = s;

			Process ps = Runtime.getRuntime().exec(cmd);
			BufferedReader br = new BufferedReader(new InputStreamReader(
					ps.getInputStream()));
			StringBuffer sb = new StringBuffer();
			String line;
			while ((line = br.readLine()) != null) {
				sb.append(line).append("\n");
			}
			String result = sb.toString();
			System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
